package com.mg.g2048.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.TextView;
import android.widget.Toast;

import com.mg.g2048.DownLoadList;
import com.mg.g2048.R;

public class MoneyListAdapter extends BaseAdapter {
	Context context = null;
	OnClickListener clickListener = null;
	
	public MoneyListAdapter(Context context,OnClickListener clickListener){
		this.context = context;
		this.clickListener = clickListener;
	}
	@Override
	public int getCount() {
		if(DownLoadList.name == null)
			return 0;
		else
			return DownLoadList.name.length;
	}

	@Override
	public Object getItem(int arg0) {
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		return 0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup parent) {
		LayoutInflater inflater = LayoutInflater.from(context);  
		
		View item = inflater.inflate(R.layout.list_item, parent, false); 
		TextView name = (TextView) item.findViewById(R.id.name);
		TextView about = (TextView) item.findViewById(R.id.about);
		
		// 起点
		name.setText(DownLoadList.name[arg0]);
		// 终点
		about.setText(DownLoadList.about[arg0]);
		
		item.setId(arg0);
		//设置监听器
		item.setOnClickListener(clickListener);
		return item;
	}

}



